#ifndef TEST_HPP
#define TEST__HPP

#include <iostream>

// 展开命名空间
// using namespace std;

class Date
{
private:
    // 成员变量
    int _year;
    int _month;
    int _day;

public:
    // 默认构造函数
    Date(int year = 1, int month = 1, int day = 1)
        : _year(), _month(month), _day(day)
    {
        std::cout << "Date(int year = 1, int month = 1, int day = 1): _year(), _month(month), _day(day)" << std::endl;
    }

    // 拷贝构造函数
    Date(const Date &rhs)
    {
        // 现代写法(具有实际意义)
        // Date tmp(rhs._year, rhs._month, rhs._day);
        // std::swap(_year, tmp._year);
        // std::swap(_month, tmp._month);
        // std::swap(_day, tmp._day);

        std::cout << "Date(const Date &rhs)" << std::endl;
        _year = rhs._year;
        _month = rhs._month;
        _day = rhs._day;
    }

    // 赋值运算符重载
    // 注意：返回值的意义-->连续性
    Date &operator=(const Date &rhs)
    {
        std::cout << "Date &operator=(const Date &rhs)" << std::endl;
        _year = rhs._year;
        _month = rhs._month;
        _day = rhs._day;

        return *this;
    }

    // 标准输入输出流重载(简易)
    // 注意：返回值的意义-->连续性
    friend std::istream &operator>>(std::istream &input, Date &rhs)
    {
        // std::cout << "input the date: " << std::endl;
        std::cin >> rhs._year >> rhs._month >> rhs._day;

        return input;
    }

    friend std::ostream &operator<<(std::ostream &output, const Date &rhs)
    {
        // std::cout << "output the date: " << std::endl;
        std::cout << "_year:" << rhs._year << std::endl;
        std::cout << "_month:" << rhs._month << std::endl;
        std::cout << "_day:" << rhs._day << std::endl;

        return output;
    }

    // 运算重载
    // 注意：代码复用
    bool operator>(const Date &rhs) const
    {
        // 年判断
        if (_year > rhs._year)
        {
            return true;
        }
        else if (_year < rhs._year)
        {
            return false;
        }

        // 月判断
        if (_month > rhs._month)
        {
            return true;
        }
        else if (_month < rhs._month)
        {
            return false;
        }

        // 日判断
        if (_day > rhs._day)
        {
            return true;
        }
        else if (_day < rhs._day)
        {
            return false;
        }

        return false;
    }

    bool operator<(const Date &rhs) const
    {
        if (rhs > *this)
        {
            return true;
        }

        return false;
    }

    bool operator>=(const Date &rhs) const
    {
        if (*this > rhs || *this == rhs)
        {
            return true;
        }

        return false;
    }

    bool operator<=(const Date &rhs) const
    {
        if (*this < rhs || *this == rhs)
        {
            return true;
        }

        return false;
    }

    bool operator==(const Date &rhs) const
    {
        if (_year == rhs._year && _month == rhs._month && _day == rhs._day)
        {
            return true;
        }

        return false;
    }

    bool operator!=(const Date &rhs) const
    {
        if (*this == rhs)
        {
            return false;
        }

        return true;
    }
    // 前置
    Date &operator++()
    {
        std::cout << "Date &operator++()" << std::endl;
    }

    Date &operator--()
    {
        std::cout << "Date &operator--()" << std::endl;
    }

    // 后置
    Date operator++(int)
    {
        std::cout << "Date operator++(int)" << std::endl;
    }

    Date operator--(int)
    {
        std::cout << "Date operator--(int)" << std::endl;
    }

    // 析构函数
    ~Date()
    {
        std::cout << "~Data()" << std::endl;
        // ...
    }
};

#endif